using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GameAOT;

namespace IQIGame.Onigao.GamePlay
{
    public class UIRemarkSet : UIBaseWindow
    {
        #region Template Generate,don't modify
        protected class UIB_UIRemarkSet
        {
            #region ObjectBinding Generate
            public IQIGame.Onigao.Framework.ExButton btnCancel { protected set; get; }
            public IQIGame.Onigao.Framework.ExButton btnConfirm { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textName { protected set; get; }
            public IQIGame.Onigao.Framework.ExButton btnBack { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExButton>("btnCancel", out var __tbv0);
                this.btnCancel = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExButton>("btnConfirm", out var __tbv1);
                this.btnConfirm = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textName", out var __tbv2);
                this.textName = __tbv2;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExButton>("btnBack", out var __tbv3);
                this.btnBack = __tbv3;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region Window Config
        /// <summary>
        /// 静态配置
        /// </summary>
        private static UICreateConfig _createConfig = new()
        {
            prefabName = nameof(UIRemarkSet),
            layer = EUILayer.Pop,
        };

        /// <summary>
        /// 创建UI的配置
        /// </summary>
        public override IUICreateConfig createConfig => _createConfig;
        #endregion Window Config

        #region fields
        long id;


        #endregion fields

        #region properties

        protected UIB_UIRemarkSet ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;



        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIRemarkSet();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow(UIBaseData data)
        {
            var d = data as UD_RemarkSet;
            id = d.friendId;
        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {
            this.ui.btnBack.AddClickEvent(OnClickBack);
            this.ui.btnCancel.AddClickEvent(OnClickBack);
            this.ui.btnConfirm.AddClickEvent(OnClickConfirm);
        }

        private void OnClickConfirm()
        {
            FriendModule.NetCore.CS_setRemark(id, this.ui.textName.text);
            this.Close();
        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds

        private void OnClickBack()
        {
            this.Close();
        }

        #endregion methonds
    }
}